home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / macintosh-c / macc-carbon-demos-nonbinhex.sit / macc-carbon-demos-nonbinhex / chap18-demo-carbon events / ChooseAFolderDialog.c < prev    next >
Text File  |  2001-05-12  |  2KB  |  53 lines

  1. // *******************************************************************************************
  2. // ChooseAFolderDialog.c
  3. // *******************************************************************************************
  4.  
  5. // ………………………………………………………………………………………………………………………………………………………………………………………………………………………… includes
  6.  
  7. #include "Files.h"
  8.  
  9. // …………………………………………………………………………………………………………………………………………………………………………………………………… global variables
  10.  
  11. extern NavEventUPP    gGetFilePutFileEventFunctionUPP ;
  12. extern NavDialogRef    gModalToApplicationNavDialogRef;
  13.  
  14. // ********************************************************************* doChooseAFolderDialog
  15.  
  16. OSErr  doChooseAFolderDialog(void)
  17. {
  18.     OSErr                                            osError = noErr;
  19.     NavDialogCreationOptions    dialogOptions;
  20.     WindowRef                                    windowRef, parentWindowRef;
  21.     Str255                                        message;
  22.  
  23.     osError = NavGetDefaultDialogCreationOptions(&dialogOptions);
  24.     if(osError == noErr)
  25.     {
  26.         if((osError = GetSheetWindowParent(FrontWindow(),&parentWindowRef)) == noErr)
  27.             windowRef = parentWindowRef;
  28.         else
  29.             windowRef = FrontWindow();
  30.  
  31.         GetIndString(message,rMiscStrings,sChooseAFolder);
  32.         dialogOptions.message = CFStringCreateWithPascalString(NULL,message,
  33.                                                                                                                      CFStringGetSystemEncoding());
  34.         dialogOptions.modality = kWindowModalityAppModal;
  35.  
  36.         osError = NavCreateChooseFolderDialog(&dialogOptions,gGetFilePutFileEventFunctionUPP ,
  37.                                                                                   NULL,windowRef,&gModalToApplicationNavDialogRef);
  38.  
  39.         if(osError == noErr && gModalToApplicationNavDialogRef != NULL)
  40.         {
  41.             osError = NavDialogRun(gModalToApplicationNavDialogRef);
  42.             if(osError != noErr)
  43.             {
  44.                 NavDialogDispose(gModalToApplicationNavDialogRef);
  45.                 gModalToApplicationNavDialogRef = NULL;
  46.             }
  47.         }
  48.     }
  49.  
  50.     return osError;
  51. }
  52.  
  53. // *******************************************************************************************